package org.fjsei.yewu.job.util;

import org.quartz.Job;

public final class Utility {

    private Utility() {
    }

    public static Class<? extends Job> getJobClass(String jobClassName) throws ClassNotFoundException {
        // Load the class using Class.forName()
        Class<?> clazz = Class.forName(jobClassName);

        // Check if the class implements the Job interface
        if (Job.class.isAssignableFrom(clazz)) {
            // Perform a safe cast
            return clazz.asSubclass(Job.class);
        } else {
            throw new IllegalArgumentException("The class " + jobClassName + " does not implement the Job interface.");
        }
    }
}
